package org.fast.project.service.transfer;

import org.fast.project.dao.po.UserPO;
import org.fast.project.service.bo.AddUserDO;
import org.fast.project.service.bo.UpdateUserDO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.MappingTarget;
import org.mapstruct.Mappings;

/**
 * 用户对象转换
 *
 * @author junG
 * @date 2022/11/27
 */
@Mapper(componentModel = "spring")
public interface UserDo2PoTransfer {

    /**
     *新增用户数据对象转持久化对象
     * @param addUserDO 添加用户模型对象
     * @return {@link UserPO}
     */
    UserPO addDo2Po(AddUserDO addUserDO);

    /**
     * 更新用户对象的域数据
     * @param updateUserDo 更新用户对象
     * @param userPo       被更新的持久化对象
     * @author lilith·bristol
     * @date 22:00 2020/4/22
     */
    @Mappings({
            @Mapping(target = "createTime", ignore = true),
            @Mapping(target = "updateTime", ignore = true),
            @Mapping(target = "userStatus", ignore = true)
    })
    void updateUserPo(UpdateUserDO updateUserDo, @MappingTarget UserPO userPo);
}
